<section>
	<div class="page_title">
		<h2 class="fl">更新用户</h2>
        <a class="fr top_rt_btn iconfont iconfont-chexiao" href="{:U('admin/User/index')}">管理员列表</a>
	</div>

	<ul class="ulColumn2">
		{volist name='user' id='v'}
		<input type="hidden" name="id" value="{:encrypt_id($v.id)}" />
		<li>
			<span class="item_name" style="width:120px;">用户名：</span>
			<input type="text" name="username" class="textbox textbox_295" value="{$v['username']}">
		</li>
		<li>
			<span class="item_name" style="width:120px;">密码：</span>
			<input type="password" name="password" class="textbox textbox_295">
		</li>
		<li>
			<span class="item_name" style="width:120px;">确认密码：</span>
			<input type="password"  name="repassword" class="textbox textbox_295">
		</li>
		<li>
		<li>
			<span class="item_name" style="width:120px;">是否启用：</span>
			<input type="checkbox" id="checkbox_d1" name="lock" class="chk_4" {eq name='v.lock' value='1'}checked{/eq} ><label for="checkbox_d1"></label>
		</li>

		<li>
			<span class="item_name" style="width:120px;">选择用户组：</span>
			<select class="select" name="role_id" id="platform">
				<option value="">选择用户组</option>
				{volist name="group" id="vo"}
				<option value="{$vo['id']}" {if condition='$vo["id"] eq $group_id'}selected="selected"{/if}>{$vo['title']}</option>
				{/volist}
			</select>
		</li>
		{/volist}
		<li>
			<span class="item_name" style="width:120px;"></span>
			<input type="submit" class="link_btn updateuser" style="margin-left: 300px">
		</li>
	</ul>
</section>

<script>
	$('.updateuser').click(function () {
		//检测账号
		var id = $("input[name=id]").val();
		var username = $("input[name=username]").val();
		if(!username)
		{
			msg_warning('请输入用户名');
			return false;
		}
		//密码检测
		var password = $("input[name=password]").val();
		var repassword = $("input[name=repassword]").val();
		if(password !== repassword){
			msg_warning('两次密码不一致！');
			return false;
		}
		//checkbox属性
		if($("input[type='checkbox']").is(':checked'))
		{
			var lock = 1;
		}else
		{
			var lock = 0;
		}
		//选择用户组
		var role_id = $('#platform option:selected').val();
		var data = {id:id,password:password,repassword:repassword,username:username,lock:lock,role_id:role_id};
		send_data = {
			url:U('admin/User/updateuser'),
			type:'POST',
			data:data,
			dataType:'json',
		}
		send_ajax(send_data,function(res){
			if(res.status == 1){
				msg_success('修改成功','修改成功',2000);
				setTimeout(function(){
					admin.getContentByUrl(res.data.jumpurl);
				},2000);
			}else{
				msg_error(res.message);
			}
		})
	});

	$(function(){
		//调用登陆部分的js
		$(window).keyup(function(e){
			if(e.keyCode == 13){
				$(".updateuser").click();
			}
		})
	});
</script>